package com.aihna.mall.controller.api;


import com.aihna.common.core.domain.R;
import com.aihna.mall.domain.bo.StoreBannerBo;
import com.aihna.mall.domain.bo.StoreProductBo;
import com.aihna.mall.domain.vo.StoreBannerVo;
import com.aihna.mall.domain.vo.StoreHomeVo;
import com.aihna.mall.domain.vo.StoreProductVo;
import com.aihna.mall.service.IStoreBannerService;
import com.aihna.mall.service.IStoreProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 客户端-轮播图API
 *
 * @author Joseph.Chen
 * @date 2024-04-14
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/mall")
public class ApiStoreHomeController {
    private final IStoreBannerService storeBannerService;

    private final IStoreProductService storeProductService;

    /**
     * 查询店铺轮播图列表
     */
    @GetMapping("/home")
    public R<StoreHomeVo> list() {
        StoreHomeVo storeHomeVo = new StoreHomeVo();

        StoreBannerBo storeBannerBo = new StoreBannerBo();
        List<StoreBannerVo> bannerList = storeBannerService.queryList(storeBannerBo);
        StoreProductBo storeProductBo = new StoreProductBo();
        storeProductBo.setTabType(1);
        List<StoreProductVo> productList = storeProductService.queryList(storeProductBo);

        storeHomeVo.setBannerList(bannerList);
        storeHomeVo.setProductList(productList);
        return R.ok(storeHomeVo);
    }
}
